# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site:  https://gitee.com/autumner/pythoncookbook
@software: PyCharm 
@file: shell_fileinput.py 
@time: 2019/7/31 下午3:54
@note:
脚本实现读取系统里文件内容
"""
import fileinput

with fileinput.input() as f_in:
    for line in f_in:
        print(line, end='')

"""
Example usage
use Terminal
ls | python shell_fileinput.py /etc/passwd
or
shell_fileinput.py /etc/passwd
"""
"""
第二种写法
with fileinput.input('/etc/passwd') as f:
    for li in f:
        print(f.filename(), f.lineno(), line, end='')
"""

